"""
单线程的程序：
    执行程序的时候，由系统创建一个主进程，在主进程中创建一个主线程，主线程中执行代码。

    粒度 更小
"""
import time
import threading
from threading import Thread


def fun1(i):
    # print('当前线程的名字:', threading.currentThread().name)
    # print(threading.current_thread().isAlive())
    # print(threading.current_thread().isDaemon())
    # print(threading.current_thread().ident)
    print('hello.......', i)
    print('当前线程的名字:', threading.currentThread().name)
    print('当前线程的名字2:', threading.current_thread().name)
    print(threading.current_thread().daemon)  # 守护线程
    print(threading.current_thread().isDaemon())
    print(threading.current_thread().ident)  # identity 身份 id
    print(threading.current_thread().isAlive())
    print(threading.current_thread().is_alive())


if __name__ == '__main__':
    print('__当前线程的名字:', threading.currentThread().name)

    # fun1()
    # for i in range(5):
    #     # 创建线程
    #     t = Thread(target=fun1, name="子线程"+str(i),args=(i,))
    #     # 启动线程
    #     t.start()

    # t1 = Thread(target=fun1, name="子线程1",args=(1,))
    # t2 = Thread(target=fun1, name="子线程2",args=(2,))
    # t3 = Thread(target=fun1, name="子线程3",args=(3,))
    # t4 = Thread(target=fun1, name="子线程4",args=(4,))
    # t5 = Thread(target=fun1, name="子线程5",args=(5,))
    # t1.start()
    # t2.start()
    # t3.start()
    # t4.start()
    # t5.start()
    t1 = Thread(target=fun1, name="子线程1", args=(1,))
    t1.setDaemon(True)
    t1.start()
    t1.join()
    print('over...')